<template>
    <div class="edu-page-warp">
        <el-card shadow="never">
            <div class="edu-page-title">学生信息</div>
            <hr style="margin:10px 0" />
            <el-form
                label-position="right"
                label-width="120px"
                label-suffix="："
                id="stu-info"
                v-if="currentStudent"
            >
                <el-row>
                    <el-col :span="colSpan">
                        <el-form-item :label="$t('label.stuCode')">{{currentStudent.studentId}}</el-form-item>
                    </el-col>
                    <el-col :span="colSpan">
                        <el-form-item :label="$t('label.stuName')">{{currentStudent.studentName}}</el-form-item>
                    </el-col>
                    <el-col :span="colSpan">
                        <el-form-item :label="$t('label.college')">{{currentStudent.facultyI18n}}</el-form-item>
                    </el-col>
                    <el-col :span="colSpan">
                        <el-form-item :label="$t('label.major')">{{currentStudent.professionI18n}}</el-form-item>
                    </el-col>

                    <el-col :span="colSpan">
                        <el-form-item :label="$t('label.grade')">{{currentStudent.grade}}</el-form-item>
                    </el-col>
                    <el-col :span="colSpan">
                        <el-form-item label="导师">{{currentStudent.teacher}}</el-form-item>
                    </el-col>
                    <el-col :span="colSpan">
                        <el-form-item
                            :label="$t('label.trainingLevel')"
                        >{{currentStudent.trainingLevelI18n}}</el-form-item>
                    </el-col>
                    <el-col :span="colSpan">
                        <el-form-item
                            :label="$t('label.trainingCategory')"
                        >{{currentStudent.trainingCategoryI18n}}</el-form-item>
                    </el-col>

                    <el-col :span="colSpan">
                        <el-form-item
                            :label="$t('dic.degreeType')"
                        >{{currentStudent.degreeTypeI18n}}</el-form-item>
                    </el-col>
                    <el-col :span="colSpan">
                        <el-form-item
                            :label="$t('label.formLearning')"
                        >{{currentStudent.formLearningI18n}}</el-form-item>
                    </el-col>
                    <el-col :span="colSpan" v-if="defenseType == 1">
                        <el-form-item
                            :label="$t('label.enrolDate')"
                        >{{currentStudent.enrolDate}}</el-form-item>
                    </el-col>
                    <el-col :span="colSpan" v-if="defenseType == 1">
                        <el-form-item
                            :label="$t('label.expectedGraduationDate')"
                        >{{currentStudent.expectedGraduationDate}}</el-form-item>
                    </el-col>
                </el-row>
            </el-form>
        </el-card>
        <apply-form
            v-if="currentStudent"
            :defense-type="defenseType"
            :apply-type="applyType"
            ref="applyForm"
            @close="handleReturn"
            @success="handleSave"
            :show-save-btn="true"
            :students="[currentStudent]"
        />
    </div>
</template>

<script>
import { selectStudentInfoByStuId } from "common/src/api/culture/change";
import ApplyForm from "./ApplyForm";
import mixin from 'common/src/mixins/index';
export default {
    name: "MyEarlyExam",
    mixins: [mixin],
    components: {
        ApplyForm
    },
    props: {
        defenseType: {
            default: 0
        }
    },
    data: function() {
        return {
            applyType: 0,
            currentStudent: null
        };
    },
    mounted() {
        let user = this.global.mockUser || this.global.user;
        selectStudentInfoByStuId(user.uid).then(res => {
            if (res.code == 200) {
                this.currentStudent = res.data[0];
            }
        });
    },
    computed: {
        colSpan() {
            if (this.currentStudent == null) {
                return 6;
            }
            if (
                this.currentStudent.facultyI18n &&
                this.currentStudent.facultyI18n.length >= 8
            ) {
                return 8;
            }
            if (
                this.currentStudent.professionI18n &&
                this.currentStudent.professionI18n.length >= 8
            ) {
                return 8;
            }
            return 6;
        }
    },
    methods: {
        handleReturn() {
            if (this.defenseType == 0) {
                this.$router.push("/EarlyExamManage");
                this.$store.commit("delete_tabs", "/MyEarlyExam");
            } else {
                this.$router.push("/DelayReplyManage");
                this.$store.commit("delete_tabs", "/MyDelayExam");
            }
        },
        handleSave() {
            if (this.defenseType == 0) {
                this.$router.push("/EarlyExamManage");
                this.$store.commit("delete_tabs", "/MyEarlyExam");
            } else {
                this.$router.push("/DelayReplyManage");
                this.$store.commit("delete_tabs", "/MyDelayExam");
            }
        }
    }
};
</script>

<style>
</style>